﻿#pragma once

namespace stl
{

	typedef struct tagMatrix3D MATRIX3d;

	typedef struct GEOMCALC_API tagVector3D
	{
		double x;
		double y;
		double z;
	} VECTOR3D, *PVECTOR3D, *Vector3DPtr;

	class GEOMCALC_API CVector3D : public VECTOR3D
	{
	public:
		CVector3D();
		CVector3D(double dx, double dy, double dz = 0.0);
		CVector3D(const double *pVec);
		CVector3D(const VECTOR3D& v);

		~CVector3D();

		// 操作符重载，用于矢量之间的加减运算
		CVector3D operator+(VECTOR3D v) const;
		void operator+=(VECTOR3D v);
		CVector3D operator-(VECTOR3D v) const;
		void operator-=(VECTOR3D v);

		// 
		CVector3D operator*(double d) const;
		void operator*=(double d);

		CVector3D operator/(double d) const;
		void operator/=(double d);

		CVector3D operator*(VECTOR3D v) const; // 叉乘
		CVector3D CrossProduct(const VECTOR3D& v);

		double operator|(VECTOR3D v) const; // 点乘
		double DotProduct(const VECTOR3D& v);

		CVector3D operator*(const MATRIX3d& matrix) const;
		void operator*=(const MATRIX3d& matrix);

		double GetLength() const;
		double GetLengthXY() const;
		double GetLengthYZ() const;
		double GetLengthZX() const;

		CVector3D Normal() const; // 单位矢量
		void Normallize(); // 单位化矢量

		bool IsZeroLength() const;

		CVector3D& Negate(); // 反向

	public:
		void set(double dx, double dy, double dz = 0.0);

		// 返回[0,PI]
		double AngleTo(const CVector3D& vec);


	private:

	};

}